﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace WPSPropertyPlugin.Shapes
{
  public class PowerPointShapeObject : IOfficeShape
  {
    private dynamic ShapeObject { get; set; }

    public PowerPointShapeObject(dynamic shapeObject)
    {
      this.ShapeObject = shapeObject;
    }

    public string Name
    {
      get
      {
        return ShapeObject.Name;
      }
      set
      {
        ShapeObject.Name = value;
      }
    }

    public string Guid
    {
      get
      {
        var guid = ShapeObject.Tags[Consts.GUID_FIELD];
        if (string.IsNullOrEmpty(guid))
        {
          this.Guid = guid = System.Guid.NewGuid().ToString().ToLower();
        }
        return guid;
      }
      set
      {
        ShapeObject.Tags.Delete(Consts.GUID_FIELD);
        ShapeObject.Tags.Add(Consts.GUID_FIELD, value);
      }
    }

    public string Config
    {
      get
      {
        return ((string)ShapeObject.Tags[Consts.CONFIG_FIELD]).FromBase64();
      }
      set
      {
        ShapeObject.Tags.Delete(Consts.CONFIG_FIELD);
        ShapeObject.Tags.Add(Consts.CONFIG_FIELD, value.ToBase64());
      }
    }

    public void Delete() { }

    public void SaveConfig() { }
  }
}
